<template>
  <div>
    <div class="headline_three clearfix">
      <div v-for="(item, index) in list" :key="index" class="headline_three_banxing">
        <div class="banxing">
          <div class="imgs">
            <img v-lazy="item.cover" alt />
          </div>
          <div style="width: 100%">
            <div class="banxing_title">{{ item.name }}</div>
            <div class="banxing_button">
              学习进度{{ item.rate }}%
              <van-progress color="#FD953F" :percentage="item.rate" />
            </div>
            <div class="banxing_zhixun" @click.stop="item.is_status = !item.is_status">
              <i>包含课程：共{{ item.lesson_num }}个课程</i>
              <van-icon :name="item.is_status ? 'arrow-down' : 'arrow-up'" />
            </div>
          </div>
        </div>

        <div v-show="item.is_status">
          <div class="total">到期时间：{{ item.deadtime }}</div>
          <ul class="stage" v-for="(item1, index1) in item.stages" :key="index1">
            <li>
              <div class="imgs">
                <img v-lazy="item1.cover" alt />
              </div>
              <div>
                <div class="stage_title">{{ item1.stage_name }}</div>
                <van-button>开始学习</van-button>
              </div>
            </li>
          </ul>
        </div>
        <van-divider />
      </div>
      <div class="none" v-if="list.length < 1">
        <img :src="require('@/assets/images/quesheng-kong.png')" alt />
        <div>暂无课程</div>
      </div>
    </div>
  </div>
</template>

<script>
import { coursesLists } from '@/api/mine/course'
export default {
  data() {
    return {
      queryParams: {
        type: '2'
      },
      list: []
    }
  },

  computed: {},

  mounted() {
    this.fetchList()
  },

  methods: {
    // 获取个人信息
    fetchList() {
      coursesLists(this.queryParams).then(res => {
        const data = res.data
        data.map(b => {
          b.is_status = true
        })
        this.list = data
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.headline_three {
  .banxing {
    display: flex;
    margin: 15px 15px 0;
    .imgs {
      margin-right: 9px;
      img {
        width: 150px;
        height: 90px;
        border-radius: 5px;
        overflow: hidden;
      }
    }
  }
  .banxing_title {
    height: 36px;
    font-size: 14px;
    font-weight: 600;
    color: #333333;
    line-height: 20px;
    @include textoverflow(2);
  }
  .banxing_button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 400;
    color: #666666;
    line-height: 35px;
  }
  ::v-deep .van-progress {
    display: inline-block;
    width: 50%;
    height: 5px;
  }
  ::v-deep .van-progress__pivot {
    display: none;
  }
  .banxing_zhixun {
    font-size: 12px;
    font-weight: 400;
    color: #333333;
    // line-height: 30px;
    .van-icon {
      float: right;
      font-size: 12px;
      line-height: 20px;
    }
  }
}
.headline_three_banxing:last-child .van-divider {
  display: none;
}

.total {
  padding-left: 15px;
  font-size: 13px;
  font-weight: 400;
  color: #666666;
}
.stage {
  padding: 0 15px;
  li {
    display: flex;
    position: relative;
    box-sizing: border-box;
    // height: 94px;
    padding: 15px 0;
    border-bottom: 0.02667rem solid #ebedf0;
    .imgs {
      margin-right: 10px;
      img {
        width: 116px;
        height: 75px;
        border-radius: 5px;
      }
    }
    .stage_title {
      // height: 35px;
      font-size: 13px;
      color: #333333;
      line-height: 20px;
      @include textoverflow(2);
    }
    .van-button {
      width: 84px;
      height: 25px;
      margin-top: 10px;
      background: #009697;
      border-radius: 14px;
      font-size: 13px;
      color: #ffffff;
    }
  }
}
</style>
